package org.liveboardgames.agricola.business;

import java.util.List;

import org.liveboardgames.agricola.business.updater.CardUpdater;
import org.liveboardgames.agricola.business.updater.FarmTileUpdater;
import org.liveboardgames.agricola.business.updater.FarmUpdater;
import org.liveboardgames.agricola.business.updater.IResourceUpdater;
import org.liveboardgames.agricola.domain.Change;
import org.liveboardgames.agricola.domain.card.Card;
import org.liveboardgames.agricola.domain.common.IResourceContainer;
import org.liveboardgames.agricola.domain.farm.Farm;
import org.liveboardgames.agricola.domain.farm.FarmTile;

public class UpdaterFactory {

  public IResourceUpdater getResourceUpdater(List<Change> changes, IResourceContainer host) {
    IResourceUpdater updater = null;

    if (host instanceof Farm) {
      updater = new FarmUpdater(null, (Farm)host, changes);
    }
    else if (host instanceof FarmTile) {
      updater = new FarmTileUpdater((FarmTile)host, changes);
    }
    else if (host instanceof Card) {
      updater = new CardUpdater((Card)host, changes);
    }

    return updater;
  }

}
